#define _CRT_SECURE_NO_WARNINGS
#include"List.h"

void TestList1()
{
    ListNode* plist;
    ListInit(&plist);
    ListPushFront(plist, 1);
    ListPushFront(plist, 2);
    ListPushFront(plist, 3);
    ListPushFront(plist, 4);
    ListPushFront(plist, 5);
    ListPushFront(plist, 6);
    ListPrint(plist);

    ListPopFront(plist);
    ListPrint(plist);
    ListPopFront(plist);
    ListPopFront(plist);
    ListPopFront(plist);
    ListPopFront(plist);
    ListPrint(plist);
    ListPopFront(plist);
    ListPrint(plist);

    //ListPopFront(plist);
    ListDestory(&plist);
}

void TestList2()
{
    ListNode* plist;
    ListInit(&plist);
    ListPushBack(plist, 1);
    ListPushBack(plist, 2);
    ListPushBack(plist, 3);
    ListPushBack(plist, 4);
    ListPushBack(plist, 5);
    ListPushBack(plist, 6);
    ListPrint(plist);

    ListPopBack(plist);
    ListPrint(plist);
    ListPopBack(plist);
    ListPopBack(plist);
    ListPopBack(plist);
    ListPopBack(plist);
    ListPrint(plist);
    ListPopBack(plist);
    ListPrint(plist);

    //ListPopBack(plist);
    ListDestory(&plist);
}

void TestList3()
{
    ListNode* plist;
    ListInit(&plist);
    if (ListEmpty(plist))
        puts("list empty!!!");

    ListPushBack(plist, 1);
    ListPushBack(plist, 2);
    ListPushBack(plist, 3);
    ListPushBack(plist, 4);
    ListPrint(plist);
    printf("%zu\n", ListSize(plist));

    ListNode* pos = ListFind(plist, 2);
    if (!pos)
    {
        puts("nullptr!!!");
        return;
    }

    ListInsert(10, pos);
    ListPrint(plist);

    //ListPopBack(plist);
    ListDestory(&plist);
    if (!plist) puts("Destory plist!!!");
}

int main()
{
    TestList1();
    TestList2();
    TestList3();
    return 0;
}